Public Class CreditNotes
    Inherits DABase

    Public Function GetCreditNotesListBySupplier(ByVal customerID As Integer, ByVal supplierID As Integer) As DataSet
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[GetCreditNotesByCustomerIdAndSupplier]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add("@CUSTOMER_ID_FK", customerID)
        sqlCommand.Parameters.Add("@SUPPLIER_ID_FK", supplierID)

        Dim ds As New DataSet

        Dim da As New SqlDataAdapter(sqlCommand)

        da.Fill(ds)

        Return ds
    End Function


    Protected Overrides Function getDeleteCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[CreditNotesDeleteCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CN_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CN_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CUSTOMER_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CUSTOMER_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DESCRIPTION", System.Data.SqlDbType.VarChar, 2000, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DESCRIPTION", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NUMBER", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NUMBER", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_VALUE_", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "VALUE_", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SUPPLIER_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SUPPLIER_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))

        Return sqlCommand

    End Function

    Protected Overrides Function getInsertCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[CreditNotesInsertCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CUSTOMER_ID_FK", System.Data.SqlDbType.Int, 4, "CUSTOMER_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NUMBER", System.Data.SqlDbType.VarChar, 10, "NUMBER"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DESCRIPTION", System.Data.SqlDbType.VarChar, 2000, "DESCRIPTION"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_DATE", System.Data.SqlDbType.DateTime, 8, "CREATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@VALUE_", System.Data.SqlDbType.Money, 8, "VALUE_"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_BY", System.Data.SqlDbType.Int, 4, "CREATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_BY", System.Data.SqlDbType.Int, 4, "UPDATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, "UPDATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SUPPLIER_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "SUPPLIER_CODE_ID_FK"))

        Return sqlCommand
    End Function

    Protected Overrides Function getSelectCommand(ByVal keys() As Object) As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[CreditNotesSelectCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

        Dim Param As SqlParameter
        Param = New System.Data.SqlClient.SqlParameter("@CN_ID_PK", System.Data.SqlDbType.Int, 4, "CN_ID_PK")
        Param.Value = keys(0)
        sqlCommand.Parameters.Add(Param)

        Return sqlCommand

    End Function

    Protected Overrides Function getUpdateCommand() As System.Data.SqlClient.SqlCommand
        Dim sqlCommand As New SqlClient.SqlCommand

        sqlCommand.CommandText = "[CreditNotesUpdateCommand]"
        sqlCommand.CommandType = System.Data.CommandType.StoredProcedure
        sqlCommand.Connection = Me.Connection
        sqlCommand.Transaction = Me.Transaction

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CUSTOMER_ID_FK", System.Data.SqlDbType.Int, 4, "CUSTOMER_ID_FK"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NUMBER", System.Data.SqlDbType.VarChar, 10, "NUMBER"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DESCRIPTION", System.Data.SqlDbType.VarChar, 2000, "DESCRIPTION"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_DATE", System.Data.SqlDbType.DateTime, 8, "CREATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@VALUE_", System.Data.SqlDbType.Money, 8, "VALUE_"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CREATED_BY", System.Data.SqlDbType.Int, 4, "CREATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_BY", System.Data.SqlDbType.Int, 4, "UPDATED_BY"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, "UPDATED_DATE"))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SUPPLIER_CODE_ID_FK", System.Data.SqlDbType.Int, 4, "SUPPLIER_CODE_ID_FK"))

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CN_ID_PK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CN_ID_PK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CREATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CREATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CUSTOMER_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CUSTOMER_ID_FK", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DESCRIPTION", System.Data.SqlDbType.VarChar, 2000, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DESCRIPTION", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NUMBER", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NUMBER", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_BY", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_BY", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UPDATED_DATE", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UPDATED_DATE", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_VALUE_", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "VALUE_", System.Data.DataRowVersion.Original, Nothing))
        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SUPPLIER_CODE_ID_FK", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SUPPLIER_CODE_ID_FK", System.Data.DataRowVersion.Original, Nothing))

        sqlCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CN_ID_PK", System.Data.SqlDbType.Int, 4, "CN_ID_PK"))

        Return sqlCommand

    End Function
End Class
